﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NGUYENTHANHDONG.Excercise.Bai1
{
    public partial class HeThongDangNhap : Form
    {
        public HeThongDangNhap()
        {
            InitializeComponent();
        }

        private void btnXacNhan_Click(object sender, EventArgs e)
        {
            erpLoi.Clear();

            if(string.IsNullOrEmpty(txtTenDangNhap.Text))
            {
                erpLoi.SetError(txtTenDangNhap, "Khong dc de trong !!");
                txtTenDangNhap.Focus();
            }
            else
            {
                if(string.IsNullOrEmpty(txtMatKhau.Text))
                {
                    erpLoi.SetError(txtMatKhau, "Khong dc de trong !!");
                    txtMatKhau.Focus();
                }
                else
                {
                    ClassUser User = new ClassUser(txtTenDangNhap.Text, txtMatKhau.Text);

                    CONTROLLERS ctl = new CONTROLLERS();
                    if(ctl.Kiemtra(User) == true)
                    {
                        MessageBox.Show("Dang nhap thanh cong !!");
                    }
                    else
                    {
                        MessageBox.Show("Khong thanh cong !!");
                    }
                }
            }

        }
    }
}
